class Solution {
public:
vector<string> findRestaurant(vector<string>& list1, vector<string>& list2) {
	
	std::map<string, int> valueindex;
	vector<string> ret;
	for (int i = 0; i < list1.size(); i++)	
		valueindex.insert(make_pair(list1.at(i), i));

	string lastvale;
	int last=INT_MAX;
	for (int i = 0; i<list2.size() ; i++){
		string v = list2.at(i);
		auto itr = valueindex.find(v);
		if (itr == valueindex.end())
			continue;
		
		if (last > itr->second + i)
			lastvale = itr->first;

	}

	ret.push_back(lastvale);

	return ret;
}
};